package ltd.dujiabao.dualwrite.datasource;

import ltd.dujiabao.dualwrite.config.SwitchDataSourceProperties;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author Bowie Du
 * @date 2025/10/31 23:51
 */

public class SwitchableDataSource extends AbstractRoutingDataSource {

    private final SwitchDataSourceProperties properties;

    public SwitchableDataSource(SwitchDataSourceProperties properties) {
        this.properties = properties;
    }

    @Override
    protected Object determineCurrentLookupKey() {
        return properties.getMode();
    }
}
